ISN project – Travel helper

Diane Sartor, Victor Aubin, Ilona Feys-Ortlepp, Doriane Rombaut, Amélie Panard

In this document, we will present you the concept of our code, how you should be able to run it and one complex but essential function we have created.

Concept of the app

For our project, we wanted to create an interface in which users can see to which countries they can travel, depending on their transportation mean, current location and time of travel they have.

We wanted to create 2 different windows:

Instructions to run the code properly

  1. Download and unzip the following folder “Travel organizer SARTOR_AUBIN_ROMBAUT_PANARD_FEYS-ORTLEPP” It contains the following files:

    • country_neighbours.json
    • EntryWindowD.py
    • MapWindowD_2.py
    • position_countries.csv
    • countries_info.csv
      Make sure all the files are present in the directory, otherwise the code will not work!
  2. In Anaconda, create a new environment

  3. In this environment, install Spyder

  4. Launch Spyder and write the following in the command console:
    a. pip install geopy
    b. pip install tkintermapview
    c. pip install Customtkinter

  5. Run the python file MapWindowD.py

  6. In the appearing introductory window, fill in your information:
    a. Your name
    b. Your current position (the position at which you want to start your travel)
    Note that if you choose to enter a city which is not very well-known, it is better to enter the postal code of this city and even the country in which it is located in.
    Also note that no matter the city chosen, the code will start its computations with the capital of the country in which the city chosen is in.
    c. The maximum amount of time you have to travel
    d. Your mode of transport: either plane or car (by car, the travel route will only be by land; the plane option allows the route to pass over the sea and oceans)
    Note that it is not possible to choose both plane and car.

  7. Click on Save then Next

  8. A window called MapWindow appears, in which we can see the reachable countries pinned on the map
    If the mode of transportation chosen was “car”, by clicking on the scroll menu, you will be able to see in blue the route to get to the different countries.

  9. To see the informations about a country, click on the corresponding pin and they will appear in the window. Here is a key of all the information displayed:
    a. The population of the country
    b. The annual change in population in percentage form
    c. The land area of the country in km2
    d. The country’s population density in habitants per kilometer
    e. The median age of the country’s population

For the case of a travel by car, the countries you need to pass by to reach your destination are listed.
You can also choose to change the appearance of the map, zoom and move it as you want, as well as the appearance of the window.

The code complexity

First, it has a database imported from the csv file “country_info”. It converts it into a dictionary that takes as key the abbreviation of the country and as values all possible information of the country, like its land area, its population and the most important the latitude and the longitude of its capital.

Indeed for the computation of the distance between two countries, we chose to only look at the distance between the capitals as the crow flies. We assumed that for turism people would tend to go to the capital of a country if they just visit it for a week-end. And in addition, when choosing to go there by plane, it should always be possible to join a capital city.

We used the GPS coordinates of the points to compute the distance between them in a straight line, even though it might not be really representative of reality. In the end, the differences between reality and what we compute are not so important.

The function compute_reachable_countries

The key function of our program is the function reachable_countries. Indeed it is the one that selects only the countries where the user can go within the time lap he has chosen and starting at its initial location.
The distance traveled is taking into consideration the means of transport you have chosen.
It combines several functions like :

In the end, compute_reachable_countries verifies if the distance between our initial country and the potential final one is smaller than the distance that can be traveled in the user’s amount of time. If so, it is added to the reachable_country list.
In the special case of travel by car, it does not only find the reachable countries but it also finds the path (i.e. the different countries to pass by) to go there.

def compute_reachable_countries(self):
        reachable_country = [ ]
        time_hours = self.convert_time_hours()
        position = self.get_country_code_from_address(self.entry_position)
        dist=self.get_dist_from_time_and_transport(time_hours)
        distance_countries=0
        if self.choice_air.get()==1 :
            for country_code in self.countries_info.keys() :
                distance_countries = self.distance_countries(position,country_code)
                if distance_countries < dist and distance_countries != 0 :
                    reachable_country.append(country_code)
                    print(reachable_country)            
        elif self.choice_earth.get()==1:
            reachable_country , total_path, path = self.create_bfs(position)
            print(reachable_country)          
              return reachable_country

Sources used for the code

To help us for the display of the map and windows, we used the following two libraries:

CustomTkinter

TkinterMapView

We also used an API (application programming interface) to help us with the whole geopgraphical aspect of our code, that is country delimitations, cities, coordinates etc…

Geopy

Finally, we sometimes used help of chatGPT to help us correct some parts of the code and to create some basic functions. For instance we asked for :